/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.kj.entity;

import com.jeesite.common.mybatis.annotation.JoinTable;
import org.hibernate.validator.constraints.Length;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

import java.math.BigDecimal;
import java.util.Date;

/**
 * kj_badgeEntity
 * @author hzy
 * @version 2021-07-17
 */
@Table(name="kj_badge", alias="a", columns={
		@Column(name="id", attrName="id", label="id", isPK=true),
		@Column(name="name", attrName="name", label="name", queryType=QueryType.LIKE),
		@Column(name="img", attrName="img", label="徽章头像", isQuery=false),
		@Column(name="gain_img", attrName="gainImg", label="徽章头像", isQuery=false),
		@Column(name="description", attrName="description", label="描述", isQuery=false),
		@Column(name="badge_type_id", attrName="kjBadgeType.id", label="徽章类别id"),
		@Column(name="badge_type_name", attrName="kjBadgeType.typeName", label="徽章类别名"),
		@Column(name="limit_integral", attrName="limitIntegral", label="最低获得积分"),
		@Column(includeEntity=DataEntity.class),
	}, joinTable={
		@JoinTable(type= JoinTable.Type.LEFT_JOIN, entity= KjBadgeType.class, alias="t",
				on="t.id = a.badge_type_id",
				columns={@Column(includeEntity=KjBadgeType.class)})
}, orderBy="a.zindex asc, a.update_date DESC"
)
public class KjBadge extends DataEntity<KjBadge> {

	private static final long serialVersionUID = 1L;
	private String name;		// name
	private String img;		// 徽章头像
	private String gainImg;		// 徽章头像
	private String description;		// 描述
	private String badgeTypeId;
	private String badgeTypeName;
	private BigDecimal limitIntegral;
	private KjBadgeType kjBadgeType;

	public KjBadge() {
		this(null);
	}

	public KjBadge(String id){
		super(id);
	}

	@Length(min=0, max=255, message="name长度不能超过 255 个字符")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Length(min=0, max=255, message="徽章头像长度不能超过 255 个字符")
	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getBadgeTypeId() {
		return badgeTypeId;
	}

	public void setBadgeTypeId(String badgeTypeId) {
		this.badgeTypeId = badgeTypeId;
	}

	public String getBadgeTypeName() {
		return badgeTypeName;
	}

	public void setBadgeTypeName(String badgeTypeName) {
		this.badgeTypeName = badgeTypeName;
	}

	public BigDecimal getLimitIntegral() {
		return limitIntegral;
	}

	public void setLimitIntegral(BigDecimal limitIntegral) {
		this.limitIntegral = limitIntegral;
	}

	public String getGainImg() {
		return gainImg;
	}

	public void setGainImg(String gainImg) {
		this.gainImg = gainImg;
	}

	public KjBadgeType getKjBadgeType() {
		return kjBadgeType;
	}

	public void setKjBadgeType(KjBadgeType kjBadgeType) {
		this.kjBadgeType = kjBadgeType;
	}

	//所需积分小于已获得积分的徽章
	public void setLimitIntegral_lte(BigDecimal limitIntegral){
		getSqlMap().getWhere().and("limit_integral", QueryType.LTE, limitIntegral);
	}

	public Date getLimitIntegral_lte(){
		return getSqlMap().getWhere().getValue("limit_integral", QueryType.LTE);
	}


}
